package com.st.thrift.demoIBM;

import com.st.thrift.demoIBM.gen.Hello;

import org.apache.thrift.TProcessor;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TTransportException;

/**
 * @author wuxianwei on 15/11/26.
 */
public class HelloServiceServer {
  /**
   * 启动 Thrift 服务器
   */
  public static void main(String[] args) {
    try {
      // 设置服务端口为 7911
      TServerSocket serverTransport = new TServerSocket(7911);
      // 关联处理器与 Hello 服务的实现
      TProcessor processor = new Hello.Processor<>(new HelloServiceImpl());

      TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
      System.out.println("Start server on port 7911...");
      server.serve();
    } catch (TTransportException e) {
      e.printStackTrace();
    }
  }
}
